﻿namespace Restaurant
{
    using System;
    using System.Linq;
    using System.Text;

    public abstract class Article
    {
        public int ArticleID { get; private set; }
        public string Name { get; private set; }
        public decimal BuyingPrice { get; private set; }
        public decimal SellingPrice { get; private set; }
        public double Quantity { get; private set; }
        public Type Type { get; private set; }

        public Article(string name, decimal sellingPrice)
        {
            this.Name = name;
            this.SellingPrice = sellingPrice;
        }

        public Article(int articleID, string name, decimal sellingPrice, decimal buyingPrice, double quantity)
        {
            this.ArticleID = articleID;
            this.Name = name;
            this.SellingPrice = sellingPrice;
            this.BuyingPrice = buyingPrice;
            this.Quantity = quantity;
            this.Type = GetGroup();
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(String.Format("{0} - {1:C}", this.Name, this.SellingPrice));
            return sb.ToString();
        }

        public void Add(double amount)
        {
            this.Quantity += amount;
        }

        public void Take(double amount)
        {
            this.Quantity -= amount;
        }

        public Type GetGroup()
        {
            return this.GetType().DeclaringType;
        }
    }
}
